namespace SimpleWebServices.Net.Mail
{
    using System;
    using System.Collections.Specialized;
    using System.Net.Mail;
    using System.Web;
    using System.Web.Mvc;
    using Moq;
    using SimpleWebServices;
    using Xunit;

    public sealed class NotFoundMailMessageFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<NotFoundMailMessage>()
                .DerivesFrom<MailMessage>()
                .IsConcreteClass()
                .IsSealed()
                .NoDefaultConstructor()
                .Result);
        }

        [Fact]
        public void ctor_ControllerContext()
        {
            ControllerContext context = new ControllerContext()
            {
                HttpContext = new Mock<HttpContextBase>().Object
            };

            Assert.NotNull(new NotFoundMailMessage(context));
        }

        [Fact]
        public void ctor_ControllerContextNull()
        {
            Assert.Throws<ArgumentNullException>(() => new NotFoundMailMessage(null as ControllerContext));
        }

        [Fact]
        public void op_Send()
        {
            var mock = new Mock<HttpContextBase>();
            mock.SetupGet<string>(x => x.Request.HttpMethod).Returns("GET").Verifiable();
            mock.SetupGet<Uri>(x => x.Request.Url).Returns(new Uri("http://example.com/path?query")).Verifiable();
            mock.SetupGet<NameValueCollection>(x => x.Request.Headers).Returns(new NameValueCollection { { "Accept", "*/*" } }).Verifiable();

            ControllerContext context = new ControllerContext()
            {
                HttpContext = mock.Object
            };

            new NotFoundMailMessage(context).Send();

            mock.VerifyAll();
        }
    }
}